package com.clarte.dept.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.clarte.common.dao.BaseDao;
import com.clarte.model.Dept;
@Service("deptService")
@Transactional
public class DeptServiceImpl implements DeptService {
	@Resource(name="baseDao")
	private BaseDao<Dept, Integer> baseDao;

	@Override
	public void addDept(Dept dept) {
		baseDao.save(dept);
	}

	@Override
	public void delDept(Integer... id) {
		baseDao.delete(id);
	}

	@Override
	public void editDept(Dept dept) {
		baseDao.update(dept);
	}

	@Override
	public Dept getDept(int id) {
		return baseDao.get(id);
	}

	@Override
	public List<Dept> findAll() {
		return baseDao.findAll();
	}

	@Override
	public boolean isExist(String code) {
		String hql = "select count(*) from Dept t where t.code=?";
		long l = baseDao.getTotal(hql, new String[]{code});
		return l > 0;
	}
	
}
